home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / datatypes / cdt / misc / debug.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-07  |  1.2 KB  |  68 lines

  1. #ifndef DEBUG_H
  2. #define DEBUG_H
  3.  
  4. /*
  5. ** $PROJECT: C debugging macros
  6. **
  7. ** $VER: debug.h 1.1 (02.09.95)
  8. **
  9. ** by
  10. **
  11. ** Stefan Ruppert , Windthorststrasse 5 , 65439 Floersheim , GERMANY
  12. **
  13. ** (C) Copyright 1994,1995
  14. ** All Rights Reserved !
  15. **
  16. ** $HISTORY:
  17. **
  18. ** 02.09.95 : 001.001 : added assert like macro DA()
  19. ** 31.03.94 : 000.001 : initial
  20. */
  21.  
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25.  
  26. #define bug      KPrintF
  27.  
  28. #ifdef DEBUG
  29.  
  30. extern void KPrintF(char *fmt,...);
  31.  
  32. #define D(x)     x
  33. #define DBLINE    bug(__FILE__ "(%4ld):" __FUNC__ "() :",__LINE__)
  34. #define DB(x)   { DBLINE; \
  35.                         bug x; \
  36.                      }
  37.  
  38. #define DTL(x)  { struct TagItem *tstate = x; \
  39.                         struct TagItem *tag; \
  40.                         bug(__FILE__ "(%4ld):" __FUNC__ "() TagList :\n",__LINE__); \
  41.                         while((tag = NextTagItem(&tstate))) \
  42.                           bug("{0x%08lx,0x%08lx}\n",tag->ti_Tag,tag->ti_Data); \
  43.                      }
  44.  
  45. /* assert like macro */
  46. #define DA(x,expr)   { if(!(expr)) { DBLINE; bug("Fault: "); bug x; } }
  47.  
  48. #define ENTERING  bug("entering " __FUNC__ "()\n")
  49. #define LEAVING   bug("leaving " __FUNC__ "()\n")
  50.  
  51. #else
  52.  
  53. #define D(x)
  54. #define DB(x)
  55. #define DA(x,expr)
  56. #define DTL(x)
  57. #define ENTERING
  58. #define LEAVING
  59.  
  60. #endif
  61.  
  62. #ifdef __cplusplus
  63. };
  64. #endif
  65.  
  66. #endif   /* DEBUG_H */
  67.  
  68.